//
//  SendDeviceIdApi.m
//  AFNetworking
//
//  Created by tracyhenry on 2022/7/13.
//

#import "SendDeviceIdApi.h"
#import "Single.h"
#import "SiterHelp.h"
#import "AppUdp.h"
@interface SendDeviceIdApi()
@property(nonatomic,strong)NSString *ip;
@end
@implementation SendDeviceIdApi

-(id)initWithDevId:(NSString *)devId withMac:(NSString *)mac withIp:(NSString *)ip{
    if(self = [super init]){
        self.devId = devId;
        self.mac = mac;
        self.ip = ip;
    }
    return self;
}

-(BOOL)isMqttOnly{
    return NO;
}

-(id)requestCmdId{
    return @SendDeviceId;
}

-(id)requestArgumentCommand{
    [super msgChange];
    
    
    NSDate *date = [NSDate new];
    NSInteger time = (long)[date timeIntervalSince1970];
    return @{
             @"namespace":@"config",
             @"source":@"app",
             @"target":@"gateway",
             @"hw_id":self.mac,
             @"msg_id":@(self.msgId),
             @"msg":@{
                 @"CMD_CODE":[self requestCmdId],
                 @"str1":self.devId,
                 @"str2":[NSString stringWithFormat:@"%ld",time],
                 @"str3":@"",
               }
            };
}


- (void)startUdp{
    [[AppUdp shared] senData:[self requestArgumentCommand] witIp:self.ip];
}

-(BOOL)isSetApi{
    return YES;
}
@end
